home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 February: Tool Chest / Dev.CD Feb 95 / Dev.CD Feb 95.toast / Tool Chest / Interfaces / Universal Interfaces 2.0a3 / Universal AIncludes / ColorPicker.a < prev    next >
Encoding:
Text File  |  1994-11-11  |  9.7 KB  |  556 lines  |  [TEXT/MPS ]

  1. ;
  2. ;    File:        ColorPicker.a
  3. ;
  4. ;    Copyright:    © 1984-1994 by Apple Computer, Inc.
  5. ;                All rights reserved.
  6. ;
  7. ;    Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8. ;
  9. ;    Bugs?:        If you find a problem with this file, send the file and version
  10. ;                information (from above) and the problem description to:
  11. ;
  12. ;                    Internet:    apple.bugs@applelink.apple.com
  13. ;                    AppleLink:    APPLE.BUGS
  14. ;
  15. ;
  16.  
  17.     IF &TYPE('__COLORPICKER__') = 'UNDEFINED' THEN
  18. __COLORPICKER__ SET 1
  19.  
  20.  
  21.     IF &TYPE('__QUICKDRAW__') = 'UNDEFINED' THEN
  22.     include 'Quickdraw.a'
  23.     ENDIF
  24. ;        include 'Types.a'                                            ;
  25. ;            include 'ConditionalMacros.a'                            ;
  26. ;        include 'MixedMode.a'                                        ;
  27. ;        include 'QuickdrawText.a'                                    ;
  28.  
  29.     IF &TYPE('__WINDOWS__') = 'UNDEFINED' THEN
  30.     include 'Windows.a'
  31.     ENDIF
  32. ;        include 'Memory.a'                                            ;
  33. ;        include 'Events.a'                                            ;
  34. ;            include 'OSUtils.a'                                    ;
  35. ;        include 'Controls.a'                                        ;
  36. ;            include 'Menus.a'                                        ;
  37.  
  38.     IF &TYPE('__DIALOGS__') = 'UNDEFINED' THEN
  39.     include 'Dialogs.a'
  40.     ENDIF
  41. ;        include 'Errors.a'                                            ;
  42. ;        include 'TextEdit.a'                                        ;
  43.  
  44.     IF &TYPE('__CMAPPLICATION__') = 'UNDEFINED' THEN
  45.     include 'CMApplication.a'
  46.     ENDIF
  47. ;        include 'Printing.a'                                        ;
  48.  
  49.     IF &TYPE('__BALLOONS__') = 'UNDEFINED' THEN
  50.     include 'Balloons.a'
  51.     ENDIF
  52.  
  53. ;Maximum small fract value, as long
  54. MaxSmallFract                    EQU        $0000FFFF
  55.  
  56. kDefaultWidth                    EQU        383
  57. kDefaultHeight                    EQU        238
  58.  
  59. kDidNothing                        EQU        0
  60. kColorChanged                    EQU        1
  61. kOkHit                            EQU        2
  62. kCancelHit                        EQU        3
  63. kNewPickerChosen                EQU        4
  64. kApplItemHit                    EQU        5
  65.  
  66. kOriginalColor                    EQU        0
  67. kNewColor                        EQU        1
  68.  
  69. kCut                            EQU        0
  70. kCopy                            EQU        1
  71. kPaste                            EQU        2
  72. kClear                            EQU        3
  73. kUndo                            EQU        4
  74.  
  75. kMouseDown                        EQU        0
  76. kKeyDown                        EQU        1
  77. kFieldEntered                    EQU        2
  78. kFieldLeft                        EQU        3
  79. kCutOp                            EQU        4
  80. kCopyOp                            EQU        5
  81. kPasteOp                        EQU        6
  82. kClearOp                        EQU        7
  83. kUndoOp                            EQU        8
  84.  
  85. kAtSpecifiedOrigin                EQU        0
  86. kDeepestColorScreen                EQU        1
  87. kCenterOnMainScreen                EQU        2
  88.  
  89. DialogIsMoveable                EQU        1
  90. DialogIsModal                    EQU        2
  91. CanModifyPalette                EQU        4
  92. CanAnimatePalette                EQU        8
  93. AppIsColorSyncAware                EQU        16
  94. InSystemDialog                    EQU        32
  95. InApplicationDialog                EQU        64
  96. InPickerDialog                    EQU        128
  97. DetachedFromChoices                EQU        256
  98. CanDoColor                        EQU        1
  99. CanDoBlackWhite                    EQU        2
  100. AlwaysModifiesPalette            EQU        4
  101. MayModifyPalette                EQU        8
  102. PickerIsColorSyncAware            EQU        16
  103. CanDoSystemDialog                EQU        32
  104. CanDoApplDialog                    EQU        64
  105. HasOwnDialog                    EQU        128
  106. CanDetach                        EQU        256
  107.  
  108. kNoForcast                        EQU        0
  109. kMenuChoice                        EQU        1
  110. kDialogAccept                    EQU        2
  111. kDialogCancel                    EQU        3
  112. kLeaveFocus                        EQU        4
  113. kPickerSwitch                    EQU        5
  114. kNormalKeyDown                    EQU        6
  115. kNormalMouseDown                EQU        7
  116.  
  117. ; A SmallFract value is just the fractional part of a Fixed number,
  118. ;which is the low order word.  SmallFracts are used to save room,
  119. ;and to be compatible with Quickdraw's RGBColor.  They can be
  120. ;assigned directly to and from INTEGERs. 
  121. ; Unsigned fraction between 0 and 1 
  122. ; For developmental simplicity in switching between the HLS and HSV
  123. ;models, HLS is reordered into HSL. Thus both models start with
  124. ;hue and saturation values; value/lightness/brightness is last. 
  125. HSVColor                 RECORD    0
  126. hue                         ds.w    1                                    ;Fraction of circle, red at 0
  127. saturation                 ds.w    1                                    ;0-1, 0 for gray, 1 for pure color
  128. value                     ds.w    1                                    ;0-1, 0 for black, 1 for max intensity
  129. sizeof                     EQU    6
  130.                         ENDR
  131.  
  132. HSLColor                 RECORD    0
  133. hue                         ds.w    1                                    ;Fraction of circle, red at 0
  134. saturation                 ds.w    1                                    ;0-1, 0 for gray, 1 for pure color
  135. lightness                 ds.w    1                                    ;0-1, 0 for black, 1 for white
  136. sizeof                     EQU    6
  137.                         ENDR
  138.  
  139. CMYColor                 RECORD    0
  140. cyan                     ds.w    1
  141. magenta                     ds.w    1
  142. yellow                     ds.w    1
  143. sizeof                     EQU    6
  144.                         ENDR
  145.  
  146. PMColor                 RECORD    0
  147. profile                     ds.l    1
  148. color                     ds.l    5
  149. sizeof                     EQU    24
  150.                         ENDR
  151.  
  152. PickerIconData             RECORD    0
  153. scriptCode                 ds.w    1
  154. iconSuiteID                 ds.w    1
  155. helpResType                 ds.l    1
  156. helpResID                 ds.w    1
  157. sizeof                     EQU    10
  158.                         ENDR
  159.  
  160. PickerInitData             RECORD    0
  161. pickerDialog             ds.l    1
  162. choicesDialog             ds.l    1
  163. flags                     ds.l    1
  164. yourself                 ds.l    1
  165. sizeof                     EQU    16
  166.                         ENDR
  167.  
  168. ; This is the same structure as GX's gxEditMenuRecord.  Maybe use that?
  169. MenuItemInfo             RECORD    0
  170. editMenuID                 ds.w    1
  171. cutItem                     ds.w    1
  172. copyItem                 ds.w    1
  173. pasteItem                 ds.w    1
  174. clearItem                 ds.w    1
  175. undoItem                 ds.w    1
  176. sizeof                     EQU    12
  177.                         ENDR
  178.  
  179. MenuState                 RECORD    0
  180. cutEnabled                 ds.b    1
  181. copyEnabled                 ds.b    1
  182. pasteEnabled             ds.b    1
  183. clearEnabled             ds.b    1
  184. undoEnabled                 ds.b    1
  185. undoString                 ds.l    64
  186. sizeof                     EQU    262
  187.                         ENDR
  188.  
  189. ColorPickerInfo         RECORD    0
  190. theColor                 ds        PMColor
  191. dstProfile                 ds.l    1
  192. flags                     ds.l    1
  193. placeWhere                 ds.w    1
  194. dialogOrigin             ds        Point
  195. pickerType                 ds.l    1
  196. eventProc                 ds.l    1
  197. colorProc                 ds.l    1
  198. colorProcData             ds.l    1
  199. prompt                     ds.l    64
  200. mInfo                     ds        MenuItemInfo
  201. newColorChosen             ds.b    1
  202. filler                     ds.b    1
  203. sizeof                     EQU    324
  204.                         ENDR
  205.  
  206. SystemDialogInfo         RECORD    0
  207. flags                     ds.l    1
  208. pickerType                 ds.l    1
  209. placeWhere                 ds.w    1
  210. dialogOrigin             ds        Point
  211. mInfo                     ds        MenuItemInfo
  212. sizeof                     EQU    26
  213.                         ENDR
  214.  
  215. PickerDialogInfo         RECORD    0
  216. flags                     ds.l    1
  217. pickerType                 ds.l    1
  218. dialogOrigin             ds.l    1
  219. mInfo                     ds        MenuItemInfo
  220. sizeof                     EQU    24
  221.                         ENDR
  222.  
  223. ApplicationDialogInfo     RECORD    0
  224. flags                     ds.l    1
  225. pickerType                 ds.l    1
  226. theDialog                 ds.l    1
  227. pickerOrigin             ds        Point
  228. mInfo                     ds        MenuItemInfo
  229. sizeof                     EQU    28
  230.                         ENDR
  231.  
  232. EventData                 RECORD    0
  233. event                     ds.l    1
  234. action                     ds.w    1
  235. itemHit                     ds.w    1
  236. handled                     ds.b    1
  237. filler                     ds.b    1
  238. colorProc                 ds.l    1
  239. colorProcData             ds.l    1
  240. forcast                     ds.w    1
  241. sizeof                     EQU    20
  242.                         ENDR
  243.  
  244. EditData                 RECORD    0
  245. theEdit                     ds.w    1
  246. action                     ds.w    1
  247. handled                     ds.b    1
  248. filler                     ds.b    1
  249. sizeof                     EQU    6
  250.                         ENDR
  251.  
  252. ItemHitData             RECORD    0
  253. itemHit                     ds.w    1
  254. iMod                     ds.w    1
  255. action                     ds.w    1
  256. colorProc                 ds.l    1
  257. colorProcData             ds.l    1
  258. where                     ds        Point
  259. sizeof                     EQU    18
  260.                         ENDR
  261.  
  262. HelpItemInfo             RECORD    0
  263. options                     ds.l    1
  264. tip                         ds        Point
  265. altRect                     ds        Rect
  266. theProc                     ds.w    1
  267. helpVariant                 ds.w    1
  268. helpMessage                 ds.w    139
  269. sizeof                     EQU    298
  270.                         ENDR
  271.  
  272. ;    Below are the color conversion routines.
  273.     IF GENERATING68K THEN
  274.         Macro
  275.         _Fix2SmallFract
  276.             move.w    #$0001,-(sp)
  277.             dc.w     $A82E
  278.         EndM
  279.     ELSE
  280.         IMPORT    Fix2SmallFract
  281.     ENDIF
  282.  
  283.     IF GENERATING68K THEN
  284.         Macro
  285.         _SmallFract2Fix
  286.             move.w    #$0002,-(sp)
  287.             dc.w     $A82E
  288.         EndM
  289.     ELSE
  290.         IMPORT    SmallFract2Fix
  291.     ENDIF
  292.  
  293.     IF GENERATING68K THEN
  294.         Macro
  295.         _CMY2RGB
  296.             move.w    #$0003,-(sp)
  297.             dc.w     $A82E
  298.         EndM
  299.     ELSE
  300.         IMPORT    CMY2RGB
  301.     ENDIF
  302.  
  303.     IF GENERATING68K THEN
  304.         Macro
  305.         _RGB2CMY
  306.             move.w    #$0004,-(sp)
  307.             dc.w     $A82E
  308.         EndM
  309.     ELSE
  310.         IMPORT    RGB2CMY
  311.     ENDIF
  312.  
  313.     IF GENERATING68K THEN
  314.         Macro
  315.         _HSL2RGB
  316.             move.w    #$0005,-(sp)
  317.             dc.w     $A82E
  318.         EndM
  319.     ELSE
  320.         IMPORT    HSL2RGB
  321.     ENDIF
  322.  
  323.     IF GENERATING68K THEN
  324.         Macro
  325.         _RGB2HSL
  326.             move.w    #$0006,-(sp)
  327.             dc.w     $A82E
  328.         EndM
  329.     ELSE
  330.         IMPORT    RGB2HSL
  331.     ENDIF
  332.  
  333.     IF GENERATING68K THEN
  334.         Macro
  335.         _HSV2RGB
  336.             move.w    #$0007,-(sp)
  337.             dc.w     $A82E
  338.         EndM
  339.     ELSE
  340.         IMPORT    HSV2RGB
  341.     ENDIF
  342.  
  343.     IF GENERATING68K THEN
  344.         Macro
  345.         _RGB2HSV
  346.             move.w    #$0008,-(sp)
  347.             dc.w     $A82E
  348.         EndM
  349.     ELSE
  350.         IMPORT    RGB2HSV
  351.     ENDIF
  352.  
  353. ;    Below brings up the ColorPicker 1.0 Dialog
  354.     IF GENERATING68K THEN
  355.         Macro
  356.         _GetColor
  357.             move.w    #$0009,-(sp)
  358.             dc.w     $A82E
  359.         EndM
  360.     ELSE
  361.         IMPORT    GetColor
  362.     ENDIF
  363.  
  364. ;    Below are the ColorPicker 2.0 routines.
  365.     IF GENERATING68K THEN
  366.         Macro
  367.         _PickColor
  368.             move.w    #$0213,-(sp)
  369.             dc.w     $A82E
  370.         EndM
  371.     ELSE
  372.         IMPORT    PickColor
  373.     ENDIF
  374.  
  375.     IF GENERATING68K THEN
  376.         Macro
  377.         _AddPickerToDialog
  378.             move.w    #$0414,-(sp)
  379.             dc.w     $A82E
  380.         EndM
  381.     ELSE
  382.         IMPORT    AddPickerToDialog
  383.     ENDIF
  384.  
  385.     IF GENERATING68K THEN
  386.         Macro
  387.         _CreateColorDialog
  388.             move.w    #$0415,-(sp)
  389.             dc.w     $A82E
  390.         EndM
  391.     ELSE
  392.         IMPORT    CreateColorDialog
  393.     ENDIF
  394.  
  395.     IF GENERATING68K THEN
  396.         Macro
  397.         _CreatePickerDialog
  398.             move.w    #$0416,-(sp)
  399.             dc.w     $A82E
  400.         EndM
  401.     ELSE
  402.         IMPORT    CreatePickerDialog
  403.     ENDIF
  404.  
  405.     IF GENERATING68K THEN
  406.         Macro
  407.         _DisposeColorPicker
  408.             move.w    #$0217,-(sp)
  409.             dc.w     $A82E
  410.         EndM
  411.     ELSE
  412.         IMPORT    DisposeColorPicker
  413.     ENDIF
  414.  
  415.     IF GENERATING68K THEN
  416.         Macro
  417.         _GetPickerVisibility
  418.             move.w    #$0418,-(sp)
  419.             dc.w     $A82E
  420.         EndM
  421.     ELSE
  422.         IMPORT    GetPickerVisibility
  423.     ENDIF
  424.  
  425.     IF GENERATING68K THEN
  426.         Macro
  427.         _SetPickerVisibility
  428.             move.w    #$0319,-(sp)
  429.             dc.w     $A82E
  430.         EndM
  431.     ELSE
  432.         IMPORT    SetPickerVisibility
  433.     ENDIF
  434.  
  435.     IF GENERATING68K THEN
  436.         Macro
  437.         _SetPickerPrompt
  438.             move.w    #$041a,-(sp)
  439.             dc.w     $A82E
  440.         EndM
  441.     ELSE
  442.         IMPORT    SetPickerPrompt
  443.     ENDIF
  444.  
  445.     IF GENERATING68K THEN
  446.         Macro
  447.         _DoPickerEvent
  448.             move.w    #$041b,-(sp)
  449.             dc.w     $A82E
  450.         EndM
  451.     ELSE
  452.         IMPORT    DoPickerEvent
  453.     ENDIF
  454.  
  455.     IF GENERATING68K THEN
  456.         Macro
  457.         _DoPickerEdit
  458.             move.w    #$041c,-(sp)
  459.             dc.w     $A82E
  460.         EndM
  461.     ELSE
  462.         IMPORT    DoPickerEdit
  463.     ENDIF
  464.  
  465.     IF GENERATING68K THEN
  466.         Macro
  467.         _DoPickerDraw
  468.             move.w    #$021d,-(sp)
  469.             dc.w     $A82E
  470.         EndM
  471.     ELSE
  472.         IMPORT    DoPickerDraw
  473.     ENDIF
  474.  
  475.     IF GENERATING68K THEN
  476.         Macro
  477.         _GetPickerColor
  478.             move.w    #$051e,-(sp)
  479.             dc.w     $A82E
  480.         EndM
  481.     ELSE
  482.         IMPORT    GetPickerColor
  483.     ENDIF
  484.  
  485.     IF GENERATING68K THEN
  486.         Macro
  487.         _SetPickerColor
  488.             move.w    #$051f,-(sp)
  489.             dc.w     $A82E
  490.         EndM
  491.     ELSE
  492.         IMPORT    SetPickerColor
  493.     ENDIF
  494.  
  495.     IF GENERATING68K THEN
  496.         Macro
  497.         _GetPickerOrigin
  498.             move.w    #$0420,-(sp)
  499.             dc.w     $A82E
  500.         EndM
  501.     ELSE
  502.         IMPORT    GetPickerOrigin
  503.     ENDIF
  504.  
  505.     IF GENERATING68K THEN
  506.         Macro
  507.         _SetPickerOrigin
  508.             move.w    #$0421,-(sp)
  509.             dc.w     $A82E
  510.         EndM
  511.     ELSE
  512.         IMPORT    SetPickerOrigin
  513.     ENDIF
  514.  
  515.     IF GENERATING68K THEN
  516.         Macro
  517.         _GetPickerProfile
  518.             move.w    #$0422,-(sp)
  519.             dc.w     $A82E
  520.         EndM
  521.     ELSE
  522.         IMPORT    GetPickerProfile
  523.     ENDIF
  524.  
  525.     IF GENERATING68K THEN
  526.         Macro
  527.         _SetPickerProfile
  528.             move.w    #$0423,-(sp)
  529.             dc.w     $A82E
  530.         EndM
  531.     ELSE
  532.         IMPORT    SetPickerProfile
  533.     ENDIF
  534.  
  535.     IF GENERATING68K THEN
  536.         Macro
  537.         _GetPickerEditMenuState
  538.             move.w    #$0424,-(sp)
  539.             dc.w     $A82E
  540.         EndM
  541.     ELSE
  542.         IMPORT    GetPickerEditMenuState
  543.     ENDIF
  544.  
  545.     IF GENERATING68K THEN
  546.         Macro
  547.         _ExtractPickerHelpItem
  548.             move.w    #$0625,-(sp)
  549.             dc.w     $A82E
  550.         EndM
  551.     ELSE
  552.         IMPORT    ExtractPickerHelpItem
  553.     ENDIF
  554.  
  555.     ENDIF ; __COLORPICKER__
  556.